<template>
  <NavBar>
    <div slot="left" class="left" @click="backClick">
      <img src="~assets/images/common/back.svg" alt="" />
    </div>
    <div slot="center" class="center">
      <div
        v-for="(item, index) in titles"
        :key="index"
        :class="{ active: index == currentIndex }"
        @click="titleClick(index)"
      >
        {{ item }}
      </div>
    </div>
    <div slot="right"></div>
  </NavBar>
</template>

<script>
import NavBar from "components/common/navbar/NavBar";
export default {
  data() {
    return {
      titles: ["商品", "参数", "评论", "推荐"],
      currentIndex: 0,
    };
  },
  props: ["isClick"],
  components: {
    NavBar,
  },
  created() {},
  methods: {
    titleClick(index) {
      if (!this.isClick) return;
      this.currentIndex = index;
      this.$emit("titleClick", index);
    },
    backClick() {
      this.$router.back();
    },
  },
};
</script>

<style scoped>
.center {
  display: flex;
  justify-content: space-between;
  padding: 0 50px;
  font-size: 15px;
}
.left {
  height: 100%;
  display: flex;
  align-content: center;
  justify-content: center;
}
.active {
  color: var(--color-high-text);
}
</style>